Import mojo
Import agfx

Class TProperty

Private
	Field type:Int 
	Field raw:String
	
Public

	Field name:String = "default"

	'|--------------------------------------------------------------------------------
	'| 
	'|--------------------------------------------------------------------------------
	Method New(name:String,val:String)
		Self.name = name
		Self.raw = val
		Self.type = VALUE_TYPE_STRING
	End
	'|--------------------------------------------------------------------------------
	'| 
	'|--------------------------------------------------------------------------------
	Method New(name:String,val:Int)
		Self.name = name
		Self.raw = val
		Self.type = VALUE_TYPE_INT
	End
	'|--------------------------------------------------------------------------------
	'| 
	'|--------------------------------------------------------------------------------
	Method New(name:String,val:Float)
		Self.name = name
		Self.raw = String(val)
		Self.type = VALUE_TYPE_FLOAT
	End
	'|--------------------------------------------------------------------------------
	'| 
	'|--------------------------------------------------------------------------------
	Method New(name:String,val:TVector2)
		Self.name = name
		Self.raw = val.ToString()
		Self.type = VALUE_TYPE_VECTOR
	End
	
	'|--------------------------------------------------------------------------------
	'| 
	'|--------------------------------------------------------------------------------
	Method New(name:String,val:Bool)
		Self.name = name
		If(val) Then
			Self.raw = "true"
		Else
			Self.raw = "false"
		EndIf
		
		Self.type = VALUE_TYPE_BOOL
	End
	'|--------------------------------------------------------------------------------
	'| 
	'|--------------------------------------------------------------------------------
	Method Set:Void(value:Int)
		Self.raw = value
		Self.type = VALUE_TYPE_INT
	End
	'|--------------------------------------------------------------------------------
	'| 
	'|--------------------------------------------------------------------------------
	Method Set:Void(value:Float)
		Self.raw = value
		Self.type = VALUE_TYPE_FLOAT
	End
	'|--------------------------------------------------------------------------------
	'| 
	'|--------------------------------------------------------------------------------
	Method Set:Void(value:Bool)
		If value Then
			Self.raw = "true"
		Else
			Self.raw = "false"
		Endif
		Self.type = VALUE_TYPE_BOOL
	End
	
	'|--------------------------------------------------------------------------------
	'| 
	'|--------------------------------------------------------------------------------
	Method Set:Void(value:TVector2)
		Self.raw = value.ToString()
		Self.type = VALUE_TYPE_VECTOR
	End
	
	'|--------------------------------------------------------------------------------
	'| 
	'|--------------------------------------------------------------------------------
	Method Set:Void(value:String)
		Self.raw = value
		Self.type = VALUE_TYPE_STRING
	End
	'|--------------------------------------------------------------------------------
	'| 
	'|--------------------------------------------------------------------------------
	Method GetType:Int()
		Return Self.type
	End Method
	'|--------------------------------------------------------------------------------
	'| 
	'|--------------------------------------------------------------------------------
	Method ToInt:Int()
		Return Int(Self.raw)
	End
	'|--------------------------------------------------------------------------------
	'| 
	'|--------------------------------------------------------------------------------
	Method ToFloat:Float()
		Return Float(Self.raw)		
	End
	'|--------------------------------------------------------------------------------
	'| 
	'|--------------------------------------------------------------------------------
	Method ToBool:Bool()
		Local val:String = Self.raw.ToLower()
		If val = "1" Or val = "true" Or val = "t" Or val = "y" Then Return True
		Return False		
	End
	
	'|--------------------------------------------------------------------------------
	'| 
	'|--------------------------------------------------------------------------------
	Method ToVector:TVector2()
		Local str:String[] = Self.raw.Split(",")		
		Return New TVector2(Float(str[0]),Float(str[1]))
	End
	
	'|--------------------------------------------------------------------------------
	'| 
	'|--------------------------------------------------------------------------------
	Method ToString:String()
		Return Self.raw
	End
	
End Class